
#include <OsgExTool/CScreenCapture>

CScreenCapture::CScreenCapture(CaptureOperation* defaultOperation /*= 0*/, int numFrames/* = 1*/) :
ScreenCaptureHandler(defaultOperation, numFrames)
{
	il = 0;
}


bool CScreenCapture::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa)
{
	osgViewer::ViewerBase* viewer = dynamic_cast<osgViewer::View*>(&aa)->getViewerBase();
	if (!viewer) return false;

	switch (ea.getEventType())
	{
	case (osgGA::GUIEventAdapter::FRAME) :
	{
	

		 if (_startCapture)
		 {
			 // Start capturing with the currently set number of frames.
			 // If set to -1 it will capture continuously, if set to >0
			 // it will capture that number of frames.
			 _startCapture = false;
			 addCallbackToViewer(*viewer);
		 }
		 else if (_stopCapture)
		 {
			 _stopCapture = false;
			 removeCallbackFromViewer(*viewer);
		 }


		 if (getFramesToCapture() == 0)
		 {
			 setFramesToCapture(1);

		 }


	    break;
	}

	default:
		break;
	}
	return false;
}









